Rhack 0.8
by James Churchill
February 1998
------------------

Introduction
------------

This is a very old util I hacked together when I started work on RanmaRPG. It's far from complete, it's quirky, and it can be a pain in the butt, but it was exceedingly useful (I still use it on occasion...) I figured that since I had no desire to update the codebase (it's been untouched for nearly 3 years now) I may as well release it in case someone might find a use for it.

Rhack's main claim to fame is as a "table-less dialogue viewer/editor". You can set Rhack to point at a particular bank of tiles, and it will display the rom as if it was a big table of indexes into the tile bank. It's not nearly as powerful as Thingy in this regard (no support for multibyte characters, DTE, or dictionary compression), but if all you have is text which is single-byte direct indexing into a tile bank, Rhack will show you it instantly.

You can search a string using the current tile bank, with wildcards if necessary. You can even do direct replacement of data. Also, there's an infinite undo feature.


Installation
------------

Put Rhack.exe and pc8x8.fnt into a directory.

If you want to use drag-and-drop from within Windows, right-click on rhack.exe and select Properties. In the "Program" tab, write the directory that Rhack resides in into the "Working:" field.

If you're running it from the command-line, you need to be in the directory Rhack is in... so you need to use "rhack <path>/rom.smc" instead of "<path>/rhack rom.smc".

If you don't do either of the above, Rhack won't see the pc8x8.fnt file, and all the button labels will be missing.


Usage
-----

The left block of graphics is the Tile window, ala Tile Layer/any other tile editor/viewer.
The right block is the Data window, and shows the hex data in the file, as well as the current tile each byte points to.

Keys

Up/Down Arrows:	Move the tile/data window up/down one line.
PgUp/PgDown:	Move the tile/data window up/down one screen.
Home/End:	Move the tile/data window ahead/back one byte.
Tab:		Switch focus between tile/data windows (can also use the Tile/Data buttons)
0-9A-F:		When data window has focus, overwrite the hex data at the cursor.
Delete:		Remove one tile from the search/replace string.
Left/Right:	Scroll along the search/replace string. Each string can be 64 tiles long,
		longer than the screen space, so use these keys to see the whole string.
Esc:		Quits. *WARNING* if you haven't saved, you lose your changes. You don't
		get any "Do you want to save" messages.

Buttons

Select Bank:	When this is selected (it is when Rhack is first run), clicking any tile in
		the Tile window will set that tile as the first in the bank, tile 00 (the
		current bank marker.) The Data window will be updated to reflect the new
		tile bank.
Edit Tiles:	No operation (I never implemented it.)
Edit Data:	Clicking in the Data window will set the cursor to that byte (shown by a
		box around the tile and the hex byte under it.) Typing hex values will
		overwrite the byte at the cursor, as will clicking on a tile in the Tile
		window (only works for the 256 tiles after the current bank marker.)
Search:		Clicking on tiles in the Tile window (only the 256 after the current bank)
		will add them to the search string, up to a maximum of 64 tiles. Use delete
		to erase a character, and left/right to scroll along the string.
Replace:	Functions like the Search button.
Wildcard:	Adds a wildcard character to the Search or Replace string (a white ? on a
		red background.) Such tiles are "don't cares" for the Search string, and
		are the original tile in the Replace string (i.e. replacing with a ? doesn't
		change the byte.)
Find:		Finds the first match of the Search string in the rom. The Data window is
		moved to show the match at the top-left, and the entire string is boxed.
Find Next:	Finds the next match of the search string from the *second tile* currently
		displayed in the Data window. So clicking "Find" then "Find Next" repeatedly
		will show you each match in the rom, but if you scroll up after getting a
		match from "Find" or "Find Next", you'll get that match again (or an earlier
		one if you scrolled back enough.)
Replace:	Does a "Find Next" then replaces the matched string with the Replace string.

Undo:		Undoes the last change made to the rom. Each replace is counted as a single
		change. When typing into the Data window or clicking in the Tile window to
		change data, each string of bytes counts as one change, with a new batch
		being started when you click in the Data window to change the cursor
		position... i.e. Undo won't just undo the last character you changed.
Save:		Writes the edited rom to disk called "Rhack.smc". Any old "rhack.smc" will
		be renamed to "rhack.BAK".
Quit:		Quits, of course. Make sure you save *before* you click this.

It's not really as hard as it sounds. It should be obvious what's going on after you play with it for a couple of minutes.


Indicators

gpos: the location of the top left hand corner of the Tile window in the rom.
tpos: the location of the current bank marker in the rom.
dpos: the location of the top left hand corner of the Data window in the rom.

There is also a scroll box thingy beside each window (in the centre of the screen). You can't use it to change where you're looking in the rom, but it shows you where in the rom the current screen is, and how big the current screen is compared to the rest of the rom (the bigger the rom, the smaller the boxes will be.)

Limitations
-----------

Only writes to the file "rhack.smc" in the Rhack directory. Even if you're editing a .gb file... but you can always rename.

Only works on single-byte strings (no multi-byte, DTE, dictionary lookup, compression). You could work on double-byte strings if you insert wildcards between every two tiles when doing a search, I suppose...

Only knows about 8x8 2bpp tiles (i.e. Gameboy format, SNES 4 colour) since that was all I needed at the time.

